CDS 6334 - Visual Image Processing

Lecture 2: Manipulating Pixels

1. Image Formation

A digital camera captures light using a sensor array. Each sensor cell converts incoming photons into electrical signals.
๐Ÿง  Remember:

Camera Sensor = Modern replacement for photographic film.

2. Digital Images

Computers store images as discrete numerical values. Continuous real-world images must be digitized before processing.
Digitization consists of:
  • Sampling
  • Quantization

3. Sampling and Quantization

Process Description
Sampling Select points on a regular grid
Quantization Convert values into discrete integers
Exam Keyword:
Continuous Image โ†’ Sampling โ†’ Quantization โ†’ Digital Image

4. Pixel Values

A pixel is the smallest unit of a digital image.
Image Type Representation
Grayscale 0 โ€“ 255
RGB [R,G,B]
HSV [H,S,V]
Lab [L,a,b]

5. Images as Functions

An image can be represented as a mathematical function: f(x,y)
f(x,y) returns the pixel intensity at position (x,y).
๐Ÿง  Think:
Coordinates โ†’ Pixel Value

6. Image Representation in Memory

Colour images are stored as 3D arrays (matrices).
im[0,0,0] โ†’ Red value of top-left pixel
im[0,0] โ†’ Complete RGB value of top-left pixel

7. Image Bits and Storage

Number of gray levels:
L = 2แต
Storage requirement:
B = M ร— N ร— k
Frequently tested calculation.

8. Image Resolution

Resolution determines the amount of visual detail.

9. Subsampling Problems

Checkerboard Effect:
Occurs when resolution becomes too low.
False Contouring:
Occurs when gray levels are insufficient.

10. Image Size Calculation

Example:
1024 ร— 768 RGB image
8 bits per channel
๐Ÿง  Formula:

Total Bits = Width ร— Height ร— Channels ร— Bits per Channel
Common exam calculation question.

11. Pixel (Point)-Based Processing

Every pixel is transformed independently using a transformation function T.
Input Pixel โ†’ T(r) โ†’ Output Pixel

12. Arithmetic Operations

Operation Purpose
Addition Combine images
Weighted Blend Create smooth mixtures
Subtraction Detect changes
Absolute Difference Highlight changes clearly

13. Linear Contrast Stretching

Expands a narrow intensity range into a wider range.
Original: [100,150]
Target: [0,255]
Improves image contrast automatically.

14. Piecewise Linear Stretching

Multiple linear segments can be used to emphasize specific intensity ranges.
Thresholding:
Produces a binary image using only two output values.

15. Histograms

A histogram shows the distribution of pixel intensities.
๐Ÿง  Histogram tells us:
How pixel values are distributed.

16. Normalized Histogram

Each histogram bin is divided by the total number of pixels.
Sum of all normalized histogram values = 1
Represents probability distribution of pixel intensities.

17. Histogram Interpretation

Histogram Pattern Meaning
Left Concentrated Dark Image
Right Concentrated Bright Image
Narrow Low Contrast
Wide High Contrast
๐Ÿง  Histogram shows intensity distribution, NOT spatial arrangement.

18. Histogram Equalization

Histogram Equalization automatically redistributes intensity values to improve contrast.
Goal: Make the histogram more uniform.
Uses the cumulative distribution function (CDF) to remap pixel values.

19. Histogram Equalization Example (Exam Favorite)

Histogram Equalization transforms pixel values using the Cumulative Distribution Function (CDF).
๐Ÿง  Exam Workflow:

Step 1 โ†’ Calculate Histogram h(fโ‚–)
Step 2 โ†’ Calculate Probability pF(l)
Step 3 โ†’ Calculate CDF
Step 4 โ†’ Compute New Gray Level gโ‚—
Step 5 โ†’ Build New Distribution pG(l)
Column Meaning
fโ‚– Original gray level
h(fโ‚–) Number of pixels
pF(l) Probability = h(fโ‚–)/Total Pixels
CDF (ฤโ‚—) Cumulative probability
gโ‚— Equalized gray level
pG(l) New probability distribution
Example:
Total Pixels = 400
Gray Levels = 8
Therefore:
L = 8
L โˆ’ 1 = 7
Probability Formula:

pF(l) = h(fโ‚–) / Total Pixels
CDF Formula:

CDF(k) = Sum of all probabilities from level 0 to k
Equalization Formula:

gโ‚— = floor(CDF ร— (L โˆ’ 1))
Original Level CDF gโ‚—
00.191
10.443
20.654
30.815
40.896
50.956
60.986
71.007
Final Mapping:

0 โ†’ 1
1 โ†’ 3
2 โ†’ 4
3 โ†’ 5
4 โ†’ 6
5 โ†’ 6
6 โ†’ 6
7 โ†’ 7
Exam Shortcut:

After finding CDF, multiply by (L โˆ’ 1), then take FLOOR value.
๐Ÿง  Common Mistake:

Histogram Equalization does NOT guarantee a perfectly uniform histogram.
It only attempts to spread intensities more evenly.

20. Neighbourhood Processing

Pixel values can be modified using information from neighbouring pixels.
๐Ÿง  Instead of:
Pixel โ†’ Pixel

Use:
Neighbourhood โ†’ Pixel

21. Image Filtering

A filter (mask) slides across the image and performs computations using nearby pixels.
3ร—3 Averaging Filter:
Replaces each pixel with the average of itself and its neighbours.
Used for noise reduction and image smoothing.

22. Final Exam Summary

Most Important Points

  • Digitization: Sampling + Quantization
  • Pixel: Smallest image element
  • Image Function: f(x,y)
  • Storage: B = M ร— N ร— k
  • Subsampling: Can cause pixelation and checkerboard effects
  • Point Processing: Transform each pixel independently
  • Histogram: Distribution of pixel intensities
  • Histogram Equalization: Automatic contrast enhancement
  • Neighbourhood Processing: Uses surrounding pixels
  • Filtering: Foundation of image processing techniques